package com.iseastar.guojiang.wallet;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.iseastar.BaseActivity2;
import com.iseastar.guojiang.dialog.DialogMgr;
import com.shouhuobao.station.R;

/**
 * 我的钱包
 * Created by lidandan on 2018/1/16.
 */
public class MyWalletActivity extends BaseActivity2 implements View.OnClickListener {

    private TextView mAccountMoneyTV;//账户余额
    private String money = "0";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        money = getIntent().getStringExtra("money");
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void findViewById() {
        setContentView(R.layout.activity_my_wallet);
        super.findViewById();
        getAppTitle().setCommonTitle("我的钱包");
        //提现
        findViewById(R.id.with_draw_tv).setOnClickListener(this);
        //资金记录
        findViewById(R.id.money_record_tv).setOnClickListener(this);
        //客服电话
        findViewById(R.id.client_phone_tv).setOnClickListener(this);
        //账号余额
        mAccountMoneyTV = (TextView) findViewById(R.id.wallet_money_tv);
        mAccountMoneyTV.setText(money);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            //提现
            case R.id.with_draw_tv:
                Intent intent = new Intent(getContext(), CourierTakeMoneyFromAccountActivity.class);
                startActivityForResult(intent, 102);
                break;
            //资金记录
            case R.id.money_record_tv:
                startActivity(WalletMoneyRecordActivity.class);
                break;
            //拨打客服电话
            case R.id.client_phone_tv:
                DialogMgr.showPhoneDialog(getContext(), null);
                break;
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode == Activity.RESULT_OK && requestCode == 102) {
            money = data.getStringExtra("money");
            mAccountMoneyTV.setText(money);
        } else {
            super.onActivityResult(requestCode, resultCode, data);
        }
    }
}
